#include "virtual_pit8253.h"

// 初始化8253
void init8253(struct PIT8253* pit) {
    int i = 0;
    for (; i < 3; i++) {
        pit->counter[i].init_value = 0;
        pit->counter[i].mode = 0;
        pit->counter[i].is_running = false;
    }
}
// 写入8253控制寄存器
void pit_write_control(unsigned char control, struct PIT8253* pit) {
    pit->counter[control >> 6].is_running = true;
    pit->counter[control >> 6].mode = (control & 0xe) >> 1;
}
// 写入8253计数器
void pit_write_counter(unsigned char port, unsigned short value, struct PIT8253* pit) {
    pit->counter[port & 0x3].init_value = value;
}
